const koa = require("koa");
const router = require("koa-router")();
const bodyparser = require("koa-bodyparser");
const koaBody = require("koa-body"); // 控制上传文件插件
const cors = require("koa2-cors");
const upload = require("./route/upload");
const app = new koa();

app.use(cors());
// 接收参数
app.use(bodyparser());
app.use(
  koaBody({
    multipart: true,
    formidable: {
      maxFieldsSize: 10 * 1024 * 1024,
      multipart: true,
    },
  })
);

router.use("/upload", upload);

app.use(router.routes());

app.listen(666, () => {
  console.log("Server is running on port 666!");
});
